package day17.tarena.com.gui;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class TestJMenu implements ActionListener{
	public void actionPerformed(ActionEvent ae){
		String comm = ae.getActionCommand();
		System.out.println(comm);
	}
    public TestJMenu(){
    	JFrame jf = new JFrame("Test Flow");
		JMenuBar jmb = new JMenuBar();
		String[] jmLab = {"�ļ�","�༭","����"};
		String[][] jmiLab = {
			{"�½�","��","����","���","","�˳�"},
			{"����","����","����","ճ��","����"},
			{"���ڼ��±�","xx������"}};//""���ָ���
		for(int i=0;i<jmLab.length;i++){
			JMenu jm = new JMenu(jmLab[i]);
			jmb.add(jm);//ÿ��˵���Ӧ��1ά���鳤��
			for(int j=0;j<jmiLab[i].length;j++){
				if("".equals(jmiLab[i][j])){
					jm.addSeparator();
				}else{
				    JMenuItem jmi = new JMenuItem(jmiLab[i][j]);
				    jm.add(jmi);
				    jmi.addActionListener(this);
				}}
		}
		jf.setJMenuBar(jmb);		
		jf.setLocation(300,200);//���ó���λ��
		jf.setSize(300,200);
		jf.setVisible(true);//���ÿɼ�
		jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
	public static void main(String[] args) {
		new TestJMenu();
	}

}
